package com.chengqs.dfs.backupnode.server;

/**
 * <B>主类名称：</B>BackupNode<BR>
 * <B>概要说明：</B>负责同步editslog的进程<BR>
 *
 * @author: chengqs
 * @create: 2025-03-31 21:20:38
 **/
public class BackupNode {

    private volatile boolean isRunning = true;

    private FSNameSystem nameSystem;

    private NameNodeRpcClient nameNode;

    public static void main(String[] args) throws Exception {
        BackupNode backupNode = new BackupNode();
        backupNode.init();
        backupNode.start();
    }

    public void init() {
        this.nameSystem = new FSNameSystem();
        this.nameNode = new NameNodeRpcClient();
    }

    public void start() throws Exception {
        EditsLogFetcher editsLogFetcher = new EditsLogFetcher(this, this.nameSystem, this.nameNode);
        editsLogFetcher.start();

        FSImageCheckpointer fsImageCheckpointer = new FSImageCheckpointer(this, this.nameSystem, this.nameNode);
        fsImageCheckpointer.start();
    }

    public void run() throws Exception {
        while (isRunning) {
            Thread.sleep(1000);
        }
    }

    public boolean isRunning() {
        return isRunning;
    }
}
